import java.util.LinkedList;
import java.util.Stack;
//五星填数
public class B_2 {
    static int count;
    public static void main(String[] args) {
        perm(new int[]{1,2,3,4,5,6,8,9,10,12},new Stack<>());
        System.out.println(count/10);
    }
    public static void perm(int[] array, Stack<Integer> stack) {
        if(array.length == 0) {
            Object[] arr = stack.toArray();
            int[] res = new int[10];
            for (int i=0;i<=9;i++){
                res[i] = (int) arr[i];
            }
            int a1 = res[1] +res[2] + res[3] +res[4];
            int a2 = res[0] +res[2] + res[5] +res[8];
            int a3 = res[0] +res[3] + res[6] +res[9];
            int a4 = res[1] +res[5] + res[7] +res[9];
            int a5 = res[4] +res[6] + res[7] +res[8];
            if(a1==a2 && a1==a3 && a1==a4 && a1==a5)
                count++;
        } else {
            for (int i = 0; i < array.length; i++) {
                int[] tempArray = new int[array.length-1];
                System.arraycopy(array,0,tempArray,0,i);
                System.arraycopy(array,i+1,tempArray,i,array.length-i-1);
                stack.push(array[i]);
                perm(tempArray,stack);
                stack.pop();
            }
        }
    }
}